package org.example.mydeom.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.mydeom.pojo.entity.Role;

import java.util.List;

@Mapper
public interface RoleMapper extends BaseMapper<Role> {
    @Select("select r.* from role r join user_role ur on r.id=ur.role_id " +
            "where ur.user_id=#{userId} and r.deleted=0 and ur.deleted=0")
    List<Role> getByUserId(Long userId);

    @Select("select * from role where role_name=#{roleName}")
    Role getByName(String roleName);

    @Select("update role set update_time=#{updateTime},update_by=#{updateBy},deleted=0 where id=#{id}")
    void MyUpdateById(Role one);

    @Select("select count(*) from role where id=#{id} and deleted=0")
    int selDel(Long id);
}
